package cn.codesea.housework_user.ui.component;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.codesea.housework_user.R;

/**
 * 评价弹窗
 */
public class EvaDialog extends Dialog {

    @BindView(R.id.evaluation_tv)
    EditText evaluation_tv;
    @BindView(R.id.submit_tv)
    TextView submit_tv;

    private OnSubmitClickListener listener;

    public EvaDialog(Context context) {
        super(context,  R.style.DialogTheme);
        setContentView(R.layout.dialog_evaluation);
        ButterKnife.bind(this);

        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        params.height = 500;
        params.width = 500;
        window.setAttributes(params);
        this.setCancelable(true);
    }

    @OnClick(R.id.submit_tv)
    public void submit_tv(){
        listener.onSubmitClick(evaluation_tv.getText().toString());
        this.cancel();
    }

    public void setSubmit(OnSubmitClickListener listener){
        this.listener = listener;
    }

    public interface OnSubmitClickListener {
        void onSubmitClick(String eva);
    }

}
